package com.sfac.cqlg.dao;

import com.sfac.cqlg.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

// 仓库，表示是“存储”接口
@Repository

@Mapper
public interface UserDao {

    // 以注解的形式连接到接口
    @Insert("insert into account_user (create_data,email,user_name,password,userImage)"+
    "value(#{createDate},#{email},#{userName},#{password},#{userImage})")
    @Options(useGeneratedKeys = true , keyColumn = "id" , keyProperty = "id" )
    void insertUser(User user);

    // 在数据库中根据用户名去查询
    @Select("select * from account_user where user_name = #{userName} limit 1")
    User getUserByUserName(String userName);

    @Select("select * from account_user where user_name = #{userName} +" +
            " and password = #{password} limit 1")
    User getUserByUserNameAndPassword(@Param("username") String userName,
                                      @Param("username") String password);

}
